<!-- 11.02 假拼团（活动，邀请好友领金币） -->
<template>
	<view class="">
		<view class="ytop">
			<view class="yaoqing">
				分享好友使用线上成交价
			</view>
			<button class="share-friend" open-type="share">分享{{sharecon.sharenum}}个好友使用线上成交价</button>
			<view class="" v-if="issuc">
				任务已完成，使用线上成交价
			</view>
			<view class="" v-else>
				任务正在进行中
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapGetters
	} from "vuex";
	export default {
		data() {
			return {
				like_list: null,
				issuc: false,
				inimg: '',
				// 11.12 分享 信息 商品id
				sharecon: '',
				goodsid: 0
			}
		},
		onLoad(options) {
			// 11.12 分享信息
			if (options.sharecon) {
				this.sharecon = JSON.parse(options.sharecon)
			}
			// 11.12 分享 商品id
			if (options.goodsid) {
				this.goodsid = options.goodsid
			}
			// 11.12 查看分享结果
			this.taskshare(1)
			this.imgReq()
			// this.tasksu()
		},
		computed: {
			...mapGetters('mallConfig', {
				getTheme: 'getTheme',
			}),
			...mapState({
				userInfo: state => state.user.info
			}),
		},
		methods: {
			// 11.12 分享使用便宜价格购买商品
			taskshare(id) {
				let data = {
					type: 5,
					targetid: this.goodsid,
					userid: this.userInfo.options.user_id
					// test: 1
				}
				if (id == 1) {
					data.querystate = 1
				}
				this.$request({
					url: this.$api.gold.index,
					data: data
				}).then((res) => {
					if (res.data.isdone === 1) {
						this.issuc = true
					} else {
						this.issuc = false
					}
				}).catch(() => {

				})
			},
			tasksu() {
				this.$request({
					url: this.$api.gold.index,
					data: {
						type: 4,
						querystate: 1,
						targetid: 1,
						userid: this.userInfo.options.user_id
					}
				}).then((res) => {
					if (res.data.isdone === 1) {
						this.issuc = true
					} else {
						this.issuc = false
					}
				}).catch(() => {

				})
			},
			imgReq() {
				this.$request({
					url: this.$api.navs.list,
					data: {
						pid: 276,
						status: 1
					}
				}).then((res) => {
					this.inimg = res.data.list[0].icon_url
				}).catch(() => {

				})
			},
		},
		onShareAppMessage() {
			// 11.12 点击分享按钮分享人数加一 （假数据）
			this.taskshare()
			return this.$shareAppMessage({
				// title: this.config.share_title ? this.config.share_title : '双熙堂珠宝',
				// imageUrl: this.config.share_pic,
				title: '双熙堂：源自1865年皇家翡翠工匠',
				imageUrl: this.inimg,
				path: '/pages/index/index'
				// ,params: {
				// 	useridshgold: this.userInfo.options.user_id
				// }
			});
		},
	}
</script>

<style scoped lang="scss">
	.ytop {
		background: linear-gradient(#F8BD27, #F8BD27);
		// height: 450rpx;
		width: 100%;
		height: 100vh;
		font-size: 32rpx;
		text-align: center;
		// padding: 42rpx 0;
		color: #FFFFFF;
	}

	.yaoqing {
		text-align: center;
		font-size: 64rpx;
		color: #FFFFFF;
		padding: 32rpx;
		text-shadow: 0 0 10rpx #ffb4a3;
		line-height: 200rpx;
		// f6b6a8 ea470c

	}

	.share-friend {
		text-align: center;
		background: none;
		color: #FFFFFF;
		width: 456rpx;
		background-color: #f8961f;
	}
</style>
